******************************************
*  CHECK FOR EVIDENCE OF ED MANIPULATION *
******************************************
log using "${SIDCodePath}/sidsedd_check_ED_manip.log", replace
 plot histograms of # of patients per ED hour to check for ED manipulation
set scheme s2color
use trad_medicare year_dqtr edhour_2 using "${SIDDataPath}/sidsedd_merged_20102016.dta", clear
keep if trad_medicare == 1 & (year_dqtr == 2013.5 | year_dqtr == 2014.5)
gen n = 1
bys year_dqtr: egen tot_n = sum(n)

gcollapse (sum) n, by(edhour_2 year_dqtr tot_n)
gen share = n/tot_n

gen edhour_3 = edhour_2/100

gen edhour_3_offset = edhour_3 + 0.15

twoway (scatter share edhour_3 if year_dqtr == 2013.5 & edhour_3 <= 5 & edhour_3 >= -5, msymbol(th) msize(large)) ///
	(scatter share edhour_3_offset if year_dqtr == 2014.5 & edhour_3 <= 5 & edhour_3 >= -5), legend(order(1 "Pre-reform (2013Q2)" 2 "Post-reform (2014Q2)")) ///
	graphregion(color(white)) xtitle("Hours relative to midnight") ytitle("")  xline(-0.5, lcolor(black) lpattern(dash)) ///
	subtitle("Share of Medicare ED arrivals", position(11) justification(left) size(medsmall)) ///
	ylabel(, angle(horizontal))

graph export "${SIDOutputPath}/SummaryStats/share_byhour_10h_2013_2014.pdf", replace



log close